package cn.jobstart.common.algorithm;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author sunke
 * @version 1.0
 * @Description
 * @date 2023-11-01 14:43
 */
public class UniqueStringToNumberConverter {

    public static long convert(String uniqueString) {
        try {
            MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
            byte[] hash = messageDigest.digest(uniqueString.getBytes());
            BigInteger bigInteger = new BigInteger(1, hash);
            return bigInteger.longValue();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return 0;
    }

}
